home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
usr
/
include
/
sys
/
xp.h.z
/
xp.h
Wrap
C/C++ Source or Header
|
1992-04-03
|
14KB
|
427 lines
#ifndef __SYS_XP_H__
#define __SYS_XP_H__
/**************************************************************************
* *
* Copyright (C) 1989, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#ident "$Revision: 1.11 $"
/******************************************************************************
FILE = %W% %G% Xylogics Inc.
*******************************************************************************
DEFINE: misc_defs.h - miscellaneous definitions.
*******************************************************************************
DESCRIPTION:
This file defines miscellaneous constants for code compatability
and readability.
*******************************************************************************
EDIT HISTORY:
1.1 08JAN89 CLD Initial Release.
*******************************************************************************
COMMENTS:
None.
******************************************************************************/
typedef unsigned char BOOL, UCHAR, BYTE; /* 8 Bits unsigned. */
typedef unsigned short USHORT; /* 16 Bits unsigned. */
typedef short SHORT; /* 16 Bits unsigned. */
typedef unsigned int UINT; /* System dependent. */
typedef int INT; /* System dependent. */
typedef unsigned long ULONG; /* 32 Bits Unsigned. */
typedef long LONG; /* 32 Bits Unsigned. */
#define EXTERN extern
#define GLOBAL extern
#define LOCAL static
/* Bit Mask Definitions. */
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80
/* Boolean Definitions. */
#define BAD 0
#define CLEAR 0
#define FAILURE 0
#define UNSUCCESSFULL 0
#ifndef FALSE
#define FALSE 0
#endif
#define IDLE 0
#define GOOD 1
#define SET 1
#define SUCCESS 1
#define SUCCESSFULL 1
#ifndef TRUE
#define TRUE 1
#endif
#define PENDING 1
/******************************************************************************
FILE = %W% %G% Xylogics Inc.
*******************************************************************************
DEFINE: constants.h - constant definitions.
*******************************************************************************
DESCRIPTION:
This file defines the constants used by the driver. It includes
the bit masks for the controller register.
*******************************************************************************
EDIT HISTORY:
1.1 08JAN89 CLD Initial Release.
*******************************************************************************
COMMENTS:
None.
******************************************************************************/
/*
* Bit positions in the Control/Status register.
*/
/* These are the write-only bit positions: */
#define MRST BIT6 /* Module Reset. */
#define EMM BIT5 /* Enter Maintenance Mode. */
#define ARC BIT2 /* Add Register Control. */
#define CRS BIT1 /* Clear Register Status. */
/* These are the read-only bit positions: */
#define RSTA BIT6 /* Module Reset Active. */
#define MMA BIT4 /* Maintenance Mode Active. */
#define ARCP BIT2 /* Add Register Control Pending. */
#define RSP BIT1 /* Register Status Pending. */
#define FERR BIT0 /* Fatal Error. */
/* These define the lower nibble of the Command/Report register: */
#define SYNC BIT2 /* Synchronous active/complete. */
#define WRITE BIT1 /* Write active/complete. */
#define READ BIT0 /* Read active/complete. */
/*
* These define the upper nibble of the Command/Report register.
* The command code definitions are:
*/
#define OCTART_INIT 0x10 /* OCTART initialization. */
#define FLUSH_BUF 0x20 /* Flush the buffers. */
#define RESET_PORT 0x30 /* Reset port. */
#define SET_MODEM 0x40 /* Set modem control signals. */
#define GET_MODEM 0x50 /* Report modem control signals. */
#define SEND_BREAK 0x60 /* Send break. */
#define GET_ERROR 0x70 /* Report error log. */
#define GET_CPARMS 0x80 /* Get controller parameters. */
#define HXON 0x90 /* Host XON. */
#define HXOFF 0xA0 /* Host XOFF. */
/*
* Controller Status Codes.
*/
#define PARITY_ERR 0x10 /* Parity error. */
#define FRAME_ERR 0x20 /* Frame error/break. */
#define MODEM_CHG 0x30 /* Modem change. */
#define IN_OVRN 0x40 /* Input overrun. */
#define CMD_ERR 0x50 /* Command error. */
#define BUS_ERR 0x60 /* Data access bus error. */
#define TMO_ERR 0x70 /* Data access timeout error. */
#define OCT_OVF 0x80 /* OCTART overflow. */
/*
* Controller Table status field definitions:
*/
#define NOT_INIT 0x00 /* Not initialized. */
#define INITIALIZED BIT0 /* Initialized. */
/*
* Controller Table hardware configuration register definitions:
*/
#define HIGHSPEED BIT0 /* High speed crystal setting mask. */
/*
* OCTART Parameters: scc operating characteristics.
*/
#define STOP_1BIT BIT6 /* 1 Stop bit. */
#define STOP_15BIT BIT7 /* 1.5 Stop bits. */
#define STOP_2BIT (BIT6 | BIT7) /* 2 Stop bits. */
#define NO_PARITY 0x00 /* No parity. */
#define ODD_PARITY BIT4 /* Odd parity. */
#define EVEN_PARITY (BIT4 | BIT5) /* Even parity. */
#define BPC5 0x00 /* 5 Bits per character. */
#define BPC6 BIT2 /* 6 Bits per character. */
#define BPC7 BIT3 /* 7 Bits per character. */
#define BPC8 (BIT2 | BIT3) /* 8 Bits per character. */
#define NO_FLWCTL 0x00 /* No flow control. */
#define HDW_FLWCTL BIT0 /* Hardware(using RTS/CTS lines).*/
#define SFT_FLWCTL BIT1 /* Software(using XON, XOFF). */
#define ALL_FLWCTL (BIT0 | BIT1) /* Hardware and Software control.*/
/* Baud rates: */
#define BAUD_50 0x00 /* 50/100 Baud rate. */
#define BAUD_75 0x01 /* 75/150 Baud rate. */
#define BAUD_110 0x02 /* 110/220 Baud rate. */
#define BAUD_134.5 0x03 /* 134.5/269 Baud rate. */
#define BAUD_150 0x04 /* 150/300 Baud rate. */
#define BAUD_300 0x05 /* 300/600 Baud rate. */
#define BAUD_600 0x06 /* 600/1200 Baud rate. */
#define BAUD_1200 0x07 /* 1200/2400 Baud rate. */
#define BAUD_1800 0x08 /* 1800/3600 Baud rate. */
#define BAUD_2000 0x09 /* 2000/4000 Baud rate. */
#define BAUD_2400 0x0a /* 2400/4800 Baud rate. */
#define BAUD_3600 0x0b /* 3600/7200 Baud rate. */
#define BAUD_4800 0x0c /* 4800/9600 Baud rate. */
#define BAUD_7200 0x0d /* 7200/14400 Baud rate. */
#define BAUD_9600 0x0e /* 9600/19200 Baud rate. */
#define BAUD_19200 0x0f /* 19200/38400 Baud rate. */
/* Modem line signals: */
#define MDM_RTS BIT0 /* Modem RTS. */
#define MDM_DTR BIT1 /* Modem DTR. */
#define MDM_DCD BIT5 /* Modem DCD. */
#define MDM_CTS BIT6 /* Modem CTS. */
#define MDM_DSR BIT7 /* Modem DSR. */
/* Modem state masks: */
#define MDM_ENBL BIT0 /* Port enable. */
#define MDM_MCU BIT1 /* Modem change update. */
/* Port Information Table field p_status bit definitions: */
#define DOING_TCSBRK BIT0 /* Doing ioctl TCSBRK. */
#define DOING_TCSETAW BIT1 /* Doing ioctl TCSETAW/TCSETAF. */
#define DOING_TCSETAF BIT2 /* Doing ioctl TCSETAW/TCSETAF. */
#define CLOSING_PORT BIT3 /* Closing the port. */
#define BLOCK_INPUT BIT4 /* Block input data. */
#define B_FULL BIT5 /* Output buffer full. */
#define CLOSE_PENDING BIT6 /* Close requested on this port. */
#define OPENING_PORT BIT7 /* Opening a port. */
#define TIMEOUT_PND 0x100 /* Timeout pending waiting for DCD.*/
#define HANGUP 0x200 /* We have started a hangup. */
#define MODEMPORT 0x400 /* This port is a modem. */
#define MODEMFLOW 0x800 /* Modem port with hardware flow.*/
#define STOP_INPUT 0x1000 /* Driver flow control flag. */
/******************************************************************************
FILE = %W% %G% Xylogics Inc.
*******************************************************************************
DEFINE: extern.h - external definitions.
*******************************************************************************
DESCRIPTION:
This file defines the variables used by the driver that
are declared by the kernel.
*******************************************************************************
EDIT HISTORY:
1.1 08JAN89 CLD Initial Release.
*******************************************************************************
COMMENTS:
None.
******************************************************************************/
int xp_edtinit(), xp_open(), xp_close();
/******************************************************************************
FILE = %W% %G% Xylogics Inc.
*******************************************************************************
DEFINE: macros.h - driver defined macros.
*******************************************************************************
DESCRIPTION:
This file defines the macros used by the driver.
*******************************************************************************
EDIT HISTORY:
1.1 08JAN89 CLD Initial Release.
*******************************************************************************
COMMENTS:
None.
******************************************************************************/
/* CTLR()
*
* This macro returns the controller number to which a minor device
* number is attached. The system macro minor() is used to mask off
* the major device number.
*/
#define CTLR(dev) ((minor(dev) & (NUMMINOR - 1)) / NPORT)
/* PORT()
*
* This macro is used to calculate the logical port number for a device.
* The system macro minor() is used to mask off the major device number.
*/
#define PORT(dev) ((minor(dev) & (NUMMINOR - 1)) % NPORT)
/*
* MODEM()
*
* This macro is used to determine if a device number indicates
* a modem.
*/
#define MODEM(dev) (((dev) & ~(NUMMINOR - 1)) & 0x0ff)
/*
* FLOW_MODEM()
*
* This macro is used to determine if a device number indicates
* hardware flow control for the modem.
*/
#define FLOW_MODEM(dev) (((dev) & ~((NUMMINOR * 2) - 1)) & 0xff)
#define OUTPUT_MOD (MAX_OBUF - 1)
#define OBUF_EMPTY(ptr) \
(((ptr->put + sizeof(char)) & OUTPUT_MOD) == ptr->get)
#define OBUF_FULL(ptr) \
((ptr->put + (sizeof(char) * 2) & OUTPUT_MOD) == ptr->get)
#define OBUF_PUT_LOC(ptr) ( &(ptr->data[(ptr->put + 1) & OUTPUT_MOD]) )
#define OBUF_ADD(ptr, cnt, empty) \
do { \
USHORT temp; \
temp = ptr->put; \
ptr->put = ((ptr->put + (sizeof (char) * cnt)) & OUTPUT_MOD) ; \
if (ptr->get == ((temp+1) & OUTPUT_MOD)) \
empty = TRUE; \
} while (0)
#define OBUF_CONTIG(ptr) \
((((ptr->put + 1) & OUTPUT_MOD) <= ((ptr->get - 1) & OUTPUT_MOD)) \
|| (ptr->get == 0) \
? \
((ptr->get - ptr->put - 2) & OUTPUT_MOD) : (OUTPUT_MOD - ptr->put))
/*
* QTODEV()
*
* This macro searches Xp_pinfo[][].p_rdq to determine the device
* number associated with a particular read queue address.
* It returns the controller number and the port number.
*/
#define QTODEV(rq,ctlr,port) \
{ \
INT dev; \
PINFO *pinfo_ptr; \
BOOL not_found; \
dev = 0; \
not_found = TRUE; \
pinfo_ptr = &Xp_pinfo[0][0]; \
while ((dev < (NPORT * NCONTROLLER)) && (not_found)) \
{ \
if (pinfo_ptr->p_rdq == rq) \
not_found = FALSE; \
else \
{ \
pinfo_ptr++; \
dev++; \
} \
} \
port = PORT(dev); \
ctlr = CTLR(dev); \
}
/*
* WAITARCP()
*
* This macro checks and waits for ARCP to clear in the corresponding
* controller register. If it does not clear within the time expected,
* arcpclr is cleared to FALSE.
*/
#define WAITARCP(regs, orig_prio, arcpclr) \
{ \
INT counter = 255; \
\
while ((regs->csr & ARCP) && (arcpclr)) \
{ \
splx(orig_prio); \
counter--; \
if (counter) \
{ \
orig_prio = spltty(); \
DELAY(100); \
} \
else \
{ \
arcpclr = FALSE; \
orig_prio = spltty(); \
} \
} \
}
/*
* INIT_UART()
*
* This macro sets up the uart parameters for a port with the default
* values.
*/
#define INIT_UART(uart_ptr, cinfo) \
uart_ptr->u_scc = \
(USHORT)(SFT_FLWCTL | BPC8 | NO_PARITY | STOP_1BIT); \
if (cinfo->c_crystal & HIGHSPEED) \
uart_ptr->u_baud = 0xcc; \
else \
uart_ptr->u_baud = 0xee; \
uart_ptr->u_mdm_mask = MDM_MCU; \
uart_ptr->u_in_time = 20; \
uart_ptr->u_in_min = MAX_IBUF - 2; \
uart_ptr->u_xon = 0x11; \
uart_ptr->u_xoff = 0x13; \
uart_ptr->u_lowtide = (MAX_OBUF - (MAX_OBUF / 2)); \
uart_ptr->u_breaktime = 5; \
uart_ptr->u_parerr = CLEAR; \
uart_ptr->u_framerr = CLEAR; \
uart_ptr->u_ovferr = CLEAR;
/*
* SWINSIZE()
*
* This macro sets the window size for a port.
*/
#define SWINSIZE(mp) ((struct winsize *)(mp)->b_cont->b_rptr)
#endif /* __SYS_XP_H__ */